<template>
  <div class="comment">
    <div class="detail-comment" v-for="item in content" :key="item.comment_id">
      <div class="detail-comment-top">
        <div class="detail-comment-top-left">
          <div class="detail-comment-top-img">
            <img :src="item.avatar" alt="">
          </div>
          <div class="detail-comment-top-name">
            <h5>{{item.nickname}}</h5>
          </div>
        </div>
        <div class="detail-comment-top-time">
          <time>{{item.gmt_create}}</time>
        </div>
      </div>
      <div class="detail-comment-text">
        {{item.text}}
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'comment',
  data () {
    return {
      content: []
    }
  },
  methods: {
    getHomeInfo () {
      axios({
        method: 'post',
        url: 'https://bird.ioliu.cn/v2',
        params: {
          url: 'http://api.sns.sunnycare.cc/v1/comment/records'
        },
        data: {
          id: 'F00001'
        }
      }).then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      res = res.data
      if (res.code && res.data) {
        const data = res.data
        this.content = data.content
      }
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style scoped>
  .comment{margin-bottom: 12%;}
  .detail-comment {
    background-color: #fff;
    border-bottom: 1px #efefef solid;
    padding: 2% 7%;
  }

  .detail-comment-top {
    display: flex;
    justify-content: space-between;
  }

  .detail-comment-top-left {
    display: flex;
    align-items: center;
  }

  .detail-comment-top-img {
    display: flex;
    justify-content: flex-start;
  }

  .detail-comment-top-img > img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
  }

  .detail-comment-top-name {
    display: flex;
    flex-direction: column;
    margin-left: 7px;
  }

  .detail-comment-top-time {
    display: flex;
    align-items: center
  }

  .detail-comment-text {
    display: flex;
    margin-left: 50px;
    line-height: 16px;
    font-size: 14px;
  }
</style>
